<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 假设有 n 个台阶，每次可以上 1个台阶 或者 2个台阶，一共有多少种上法？
      function fn(n) {
        // 2 =>  1 1/ 2  (2)
        // 3 =>  1 1 1/ 1 2/ 2 1 (3)
        // 4 =>  1 1 1 1/ 1 1 2/ 1 2 1/ 2 1 1/ 2 2  (5)
        // 5 => 1 1 1 1 1 / 1 1 1 2 / 1 1 2 1 /1 2 2/ 1 2 1 1 / 2 1 1 1 / 2 1 2/ 2 2 1.... (8)
        // 6 => 1 1 1 1 1 1 / 1 1 1 1 2/ 1 1 1 2 1 / 1 2 1 1 / 2 1 1 1 / 2 1 2/ 2 2 1....  (13)
        const dp = [0, 1, 2]
        for (let i = 3; i <= n; i++) {
          dp[i] = dp[i - 2] + dp[i - 1]
        }
        console.log(dp)
      }
      // fn()
      console.log(fn(20))
    </script>
  </body>
</html>
